<?php
/**
 * Created by PhpStorm.
 * User: 毛文科
 * Date: 2018/8/23 0023
 * Time: 10:54
 */
namespace app\admin\model;
use think\Db;

class SettingModel
{
    /**查询打卡设置模型
     * @return $this
     */
    static public function getSetting(){
        return Db::view('card_setting',true)
            ->view('company','company_name','company.id=card_setting.company_id','left')
            ->view('departmen_table','departmen_name,number','departmen_table.id=card_setting.department_id','left')
            ->json(['attendance']);
    }

    /**添加打卡设置
     * @param $data
     * @return int|string
     */
    static public function addSetting($data){
        return Db::name('card_setting')->json(['attendance'])->insert($data);
    }

    /**删除打卡设置
     * @param $field
     * @param null $op
     * @param null $condition
     * @return int
     */
    static public function delSetting($field, $op = null, $condition = null){
        return Db::name('card_setting')->where($field,$op,$condition)->delete();
    }

    /**更新打卡设置
     * @param $data
     * @return int|string
     */
    static public function updateSetting($data){
        return Db::name('card_setting')->json(['attendance'])->update($data);
    }
}